import socket

#创建socket套接字对象
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

if False:
    while True:
        msg = input('>>').strip()
        client.sendto(msg.encode('utf-8'), ('localhost', 8086))
        data, server_addr = client.recvfrom(1024)
        print(data, server_addr)

#UDP不会粘包
client.sendto('hello'.encode('utf-8'), ('localhost', 8086))
client.sendto('world'.encode('utf-8'), ('localhost', 8086))

client.close()
